﻿using System;
using System.Collections.Generic;
using System.Text;
using Project.Core.IServices.System;
using Project.Core.IRepository.System;
using Project.Core.Repository.System;
using Project.Core.Model.System;
using System.Linq.Expressions;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Driver;
using Project.Core.Common;
using System.Linq;

namespace Project.Core.Services.System
{
    public class UserOrganizationService : IUserOrganizationService
    {
        IUserOrganizationRepository _userOrganizationRepository;

        public UserOrganizationService() { }

        public UserOrganizationService(IUserOrganizationRepository userOrganizationRepository)
        {
            _userOrganizationRepository = userOrganizationRepository;
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="Entity">实体</param>
        /// <returns></returns>
        public async Task<int> Add(UserOrganization Entity)
        {
            return await _userOrganizationRepository.Insert(Entity);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Entity">实体</param>
        /// <returns></returns>
        public async Task<bool> Delete(UserOrganization Entity)
        {
            return await _userOrganizationRepository.Delete(Entity);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id">Id</param>
        /// <returns></returns>
        public async Task<bool> Delete(int Id)
        {
            return await _userOrganizationRepository.Delete(Id);
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="expression">条件</param>
        /// <returns></returns>
        public async Task<List<UserOrganization>> Query(Expression<Func<UserOrganization, bool>> expression)
        {
            return await _userOrganizationRepository.Query(expression);
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="expression">条件</param>
        /// <returns></returns>
        public async Task<PageDataList<UserOrganization>> QueryByCondition(Expression<Func<UserOrganization, bool>> expression, bool IsPage, int PageIndex, int PageSize, Expression<Func<UserOrganization, object>> orderExpression, bool isAsc)
        {
            return await _userOrganizationRepository.QueryByCondition(expression, IsPage, PageIndex, PageSize, orderExpression, isAsc);
        }

        /// <summary>
        /// 更新用户
        /// </summary>
        /// <param name="Entity"></param>
        /// <returns></returns>
        public async Task<bool> Update(UserOrganization Entity)
        {
            return await _userOrganizationRepository.Update(Entity);
        }

        /// <summary>
        /// 查找单个数据
        /// </summary>
        /// <param name="expression">linq</param>
        /// <returns></returns>
        public async Task<UserOrganization> Find(Expression<Func<UserOrganization, bool>> expression)
        {
            return await _userOrganizationRepository.Find(expression);
        }
    }
}
